home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
manchest.lha
/
MANCHESTER
/
usenet
/
st80_pre4
/
pretty-print
/
exampleChange.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
8KB
|
305 lines
"======================================================================
|
| exampleChange.st
|
| This is part of a Smalltalk change log file (from V/Mac).
|
| Copyright (C) 1991 Mark L. Fussell.
======================================================================"!
!Stream methods !
startChunk
"For outputting chunks as seperate operations"
"Don't need to do anything... the end of the chunk is all
important".! !
!Stream methods !
middleChunkPut: aString
"Used with start/end-Chunk. Output aString doubling
embedded !!'s. Destination is receiver stream."
aString do: [ :character |
self nextPut: character.
character == $!!
ifTrue: [self nextPut: $!!]].
^ aString! !
"evaluate"
Stream removeSelector: #middleChunk:!
"evaluate"
LibFiling fileOut: ClassReaderTest
onFile: 't'
withSources: true
withSummary: true
forTex: true
texMethods: true.!
!LibGeneral1 class methods !
getMethodsCommentsOnClass: class selectors: s on: outStream texMethods:
texMethods
| inStream
code selectorWords
endSelector startComment endComment
line occur attributes b
|
s do: [:selector |
" selectorParts := ATest splitSelectors: selector.
lastSelector := selectorParts at: selectorParts size. "
code := class sourceCodeAt: selector.
code := (MethodAttributes stripAttributes: code) at: 1.
"The next string 'No source...' is broken so that this
routine won't cause a match"
((Pattern new: 'No source ','is available')
match: code index: 1) isNil ifFalse: [
b isNil ifTrue: [b := ByteDecoder standardDecoder].
b decodeCompiledMethod: (class compiledMethodAt: selector)
on: (code := WriteStream on: code).
b printPrettyOn: code.
code := code contents.
"
outStream nextPutAll: selector.
selector size < 20 ifFalse: [
outStream cr; next: 20 put: $ ;
nextPutAll: ' *** No source ','is available';cr;cr.
] ifTrue: [
outStream next: (20 - selector size) put: $ .
outStream nextPutAll: ' *** No source ','is available';cr.
].
code := nil.
"
].
(code notNil) ifTrue: [
"This next part creates a pattern to grab the
whole method declaration"
inStream := ReadStream on: code.
selectorWords := selector occurrencesOf: $:.
selectorWords > 0 ifTrue: [
1 to: selectorWords do: [:i |
inStream nextWord. "Get Selector"
inStream nextWord. "and parameter"
].
] ifFalse: [
(selector at: 1) isAlphaNumeric ifTrue: [
inStream nextWord. "only have selector"
] ifFalse: [
inStream nextWord. "Get Selector and parameter"
].
].
inStream skip: -1. "back up onto the last character
of the word (instead of LF)"
endSelector := inStream position. "Now have the end of the
message selector"
startComment := endSelector + 1.
endComment := endSelector.
"inStream countBlanks. ?? skip blanks"
line := (inStream nextLine) trimBlanks.
[(inStream atEnd not) and: [line size < 1]]
whileTrue: [ "skip over blank lines"
startComment := inStream position + 1.
line := (inStream nextLine) trimBlanks.
].
occur := (line occurrencesOf: $").
occur > 0 ifTrue: [
occur > 1 ifTrue: [
endComment := inStream position - 1. "back up from the
LF"
] ifFalse: [
inStream skipTo: $".
endComment := inStream position.
].
].
"texMethods ifTrue: [outStream nextPut: Tab]. "
outStream nextPutAll: (code copyFrom: 1 to: endSelector).
"texMethods ifTrue: [outStream nextPut: $ ;nextPut: Tab]. "
endComment > startComment ifTrue: [
(endSelector < 20 and: [endComment - startComment < 60])
ifTrue: [
outStream next: (20 - endSelector) put: $ . "pad to the
tab"
outStream nextPutAll: (code copyFrom: startComment to:
endComment) stripComments;cr.
] ifFalse: [
outStream cr.
outStream nextPutAll: (code copyFrom: startComment to:
endComment) stripComments;cr.
outStream cr.
].
] ifFalse: [
outStream cr. "add the last lines cr"
].
]. "End ifTrue"
].
^outStream
"
attributes notNil ifTrue: [
attributes printAttributesStringOn: outStream.
outStream cr.
].
"! !
!Blower methods !
atSpeedValue
<<Private>>
^120! !
!Blower methods !
initialize
<<Private>>
| sim |
on := MBoolean new.
on toFalse.
speed := MInterval new.
speed min: 0 max: 300 precision: 1.
speed addDependent: self.
sim := BlowerSim new.
internalModels := OrderedCollection with: sim.
sim initChange: speed on: on
plus: 10 minus: 20 per: #fiveSecondEvent
atSpeed: (self atSpeedValue).! !
!Blower methods !
initWindowSize
<<Public>><<Widget>>
"Tell the topWidget what size to open to"
| listLineHeight halfLineHeight |
listLineHeight := Font menuFont height + 12.
halfLineHeight := Font menuFont height + 6.
^200@((3*listLineHeight) + (halfLineHeight*1))! !
!Boiler methods !
initialize
<<Public>>
| sim |
oilValve := Valve new.
oilValve addDependent: self.
ignitor := Ignitor new.
oilFlowSensor := MBoolean new.
oilFlowSensor addDependent: self.
combustionSensor := MBoolean new.
combustionSensor addDependent: self.
tempSensor := MInterval new.
tempSensor
min: 60 max: 300 precision: 2.
tempSensor addDependent: self.
sim := BoilerSim new.
sim initChange: tempSensor on: oilValve
plus: 15 minus: 10 per: #fiveSecondEvent
atTemp: 220.
internalModels := OrderedCollection with: sim.! !
!Boiler methods !
initWindowSize
<<Public>><<Widget>>
"Tell the topWidget what size to open to"
| listLineHeight halfLineHeight |
listLineHeight := Font menuFont height + 12.
halfLineHeight := Font menuFont height + 6.
^200@((6*listLineHeight) + (halfLineHeight*0) - 2)! !
!Boiler methods !
initWindowSize
<<Public>><<Widget>>
"Tell the topWidget what size to open to"
| listLineHeight halfLineHeight |
listLineHeight := Font menuFont height + 12.
halfLineHeight := Font menuFont height + 6.
^200@((6*listLineHeight) + (halfLineHeight*0) - 2)! !
!Boiler methods !
modelReleased: who
<<Public>><<Widget>>
"The top Pane lost a model for one of its subPanes.
The whole window should close."
^true! !
!Boiler methods !
oilFlowSensor
<<Limited>>
^oilFlowSensor! !
!Boiler methods !
oilValve
<<Limited>>
^oilValve! !
TestHeating subclass: #Furnace
instanceVariableNames:
'heatingSystem state boiler blower startCoolingTime
activateDesired internalModels '
classVariableNames: ''
poolDictionaries: ''.
Furnace
comment:
'
A furnace is composed of:
Boiler
Blower
Internal values:
startCoolingTime
activateDesired
The object <state> is a Furnace state and
handles validating state moves (basically
it just prevents missspellings.)
'
.
!
!Furnace class methods !
newForSystem: aSystem
<<Public>>
^super new initForSystem: aSystem.! !